# -*- coding: utf-8 -*-
import math

def isPrime(n):
    strn = str(n)
    if strn[-1] not in ['1','7','9']:
        return False
    if n <= 1:
        return False
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True


def nn(n):
    m = 2 * (n * n) -1
    return m

def main():
    start = 56695
    listn = 10252
    mmm = 50000001

    listn = 0
    start = 2
    mmm = 10000
    for x in xrange(start,mmm):
        n = nn(x)
        if isPrime(n):
            listn += 1
            print x,n,listn
    print listn

if __name__ == '__main__':
## 30125 1815031249 5827
## 37783 2855110177 7098
## 43478 3780672967 8082
## 56694 6428419271 10252
## 197411 31931
    import time
    start = time.time()
    main()
    print('Execution time: {0} seconds'.format(time.time() - start))
